package com.xr.workFlowManage;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;

/**
 * businessCdepViewModel
 */
public class businessCdepViewModel extends DefaultViewModel {
  protected void doUpdateData(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
    // Add your code here
    super.doUpdateData(parameters, outParameters);
  }
  public void addCdep(ParameterSet parameters, ParameterSet outParameters)
  throws Exception {
	  Dataset dsCdn=getDataset("datasetCdn");
	  Dataset dsNoCdep=getDataset("datasetNoCdep");
	  dsNoCdep.moveFirst();
	  DBStatement dbs = new DBStatement();
	  while(!dsNoCdep.isLast()){
		  dbs.setSql("insert into WKF_BUSINESS_CDEP(BUSINESS_CDEP_ID,BUSINESS_FORM_ID,CDEP_TYPE,CDEP_ID,PROCESS_DEF_ID)" +
	  		"values(seq_wkf.nextval,"+dsCdn.getString("BUSINESS_FORM_ID")+",'emp',"+dsNoCdep.getString("EMPLOYEE_ID")+","+dsCdn.getString("PROCESS_DEF_ID")+")");
	      dbs.execute();
		  dsNoCdep.moveNext();
	  }

	  dbs.close();
//super.doUpdateData(parameters, outParameters);
  }
  public void delCdep(ParameterSet parameters, ParameterSet outParameters)
  throws Exception {
	  Dataset dsCdn=getDataset("datasetCdn");
	  Dataset ds=getDataset("datasetRepeat");
	  ds.moveFirst();
	  DBStatement dbs = new DBStatement();
	  while(!ds.isLast()){
		  dbs.setSql("delete from WKF_BUSINESS_CDEP where BUSINESS_CDEP_ID=" +dsCdn.getString("BUSINESS_CDEP_ID"));
	      dbs.execute();
		  ds.moveNext();
	  }  
	  dbs.close();
//super.doUpdateData(parameters, outParameters);
  }
  
  public void delRepeatSub(ParameterSet parameters, ParameterSet outParameters)
  throws Exception { 
	  Dataset ds=getDataset("datasetRepeatSub");
	  
	  DBStatement dbs = new DBStatement();
	  while(!ds.isLast()){
		  dbs.setSql("delete from WKF_BUSINESS_CDEP where business_cdep_id=" +ds.getString("BUSINESS_CDEP_ID"));
	      dbs.execute();
		  ds.moveNext();
	  }  
	  dbs.close();
//super.doUpdateData(parameters, outParameters);
  }
}
